package com.woniuxy.house.mapper;

import com.woniuxy.house.entity.PostDetail;
import com.woniuxy.house.provider.PostDetailSqlProvider;
import org.apache.ibatis.annotations.*;

/**
 * 帖子详情mapper接口
 */
public interface PostDetailMapper {

    /**
     * 通过帖子详情ID获取帖子详情
     */

    @Select("select * from house_post_detail where id=#{id}")
    @Results(id = "result", value = {
            @Result(column = "id", property = "id", id = true),
            @Result(column = "content", property = "content"),
            @Result(column = "area", property = "area"),
            @Result(column = "price", property = "price"),
            @Result(column = "house_style", property = "houseStyle"),
            @Result(column = "check_in_time", property = "checkInTime"),
            @Result(column = "lease", property = "lease"),
            @Result(column = "house_need", property = "houseNeed"),


    })
    PostDetail getById(Integer id);


    /**
     * 添加帖子详情
     */

    @Insert("insert into house_post_detail(content,area,price,house_style,check_in_time,lease,house_need) value(#{content},#{area},#{price},#{houseStyle},#{checkInTime},#{lease},#{houseNeed})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    void add(PostDetail postDetail);


    /**
     * 多条件改帖子详情
     */

    @UpdateProvider(type = PostDetailSqlProvider.class, method = "update")
    void update(PostDetail postDetail);
}
